[#231] Validate plot existence before allowing comments#236
[#231] Validate plot existence before allowing comments#236realproject7 merged 2 commits intomainfrom
Conversation
POST /api/comments now returns 400 if the (storyline_id, plot_index) pair doesn't exist in the plots table, preventing comments on non-existent plot indexes. Fixes #231 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Summary
The new plot-existence validation covers the happy path, but it currently drops database errors from the lookup and misreports them as a client-side 400. That turns transient/server failures into a false "plot does not exist" response.
Findings
- [medium] The
plotsexistence query ignores itserrorresult, so any lookup failure is treated as a missing plot instead of a server error.- File:
src/app/api/comments/route.ts:117 - Suggestion: capture
errorfrom theserverClient.from("plots")...query and returnerror(Database error: ${dbError.message}, 500)before the not-found check.
- File:
Decision
Requesting changes because the new validation path currently hides real database failures behind a misleading 400 response.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Summary
Re-review complete. The plot-existence validation now correctly handles database lookup failures as 500 responses and only returns 400 when the plot tuple is genuinely missing.
Findings
- None. The validation path now matches issue #231's acceptance criteria without masking server-side failures.
Decision
Approving because the requested fix is in place and the route behavior now cleanly distinguishes invalid input from database errors. CI was still pending at the time of review.
Summary
/api/commentsnow queries theplotstable to verify the(storyline_id, plot_index, contract_address)tuple exists before inserting"Plot does not exist"if the plot is not foundTest plan
Fixes #231
🤖 Generated with Claude Code